
import java.io.*;
import POJO.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author Sibrand
 */
public class foaf extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            HttpSession sess = request.getSession();
            if (request.getMethod().equals("POST") && sess.getAttribute("user") != null && request.getParameter("user") != null && ((User) sess.getAttribute("user")).username != null && ((User) sess.getAttribute("user")).username.compareTo(request.getParameter("user")) == 0) {
                Foaf f = new Foaf(((User) sess.getAttribute("user")));
                out.print("<textarea rows=\"15\" cols=\"0\" style=\"text-align:left; width: 100%;\" id=\"FOAF\">");
                out.print(f.getString());
                out.print("</textarea>");
            } else {
                out.print("Unauthorized entrance.");
            }
        } finally {
            out.close();
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    public String getServletInfo() {
        return "Short description";
    }
}
